<template>
  <el-dialog :visible="isShow" @close="closeEvent">
    <template #title>题目预览</template>
    <div class="box">
      <p>
        【题型】：<span>{{ dataList.questionType | difficult }}</span>
      </p>
      <p>
        【编号】：<span>{{ dataList.id }}</span>
      </p>
      <p>
        【难度】：<span>{{ dataList.difficulty | TypeQuestion }}</span>
      </p>
      <p>
        【标签】：<span>{{ dataList.tags }}</span>
      </p>
      <p>
        【学科】：<span>{{ nameList.subject }}</span>
      </p>
      <p>
        【目录】：<span>{{ nameList.catalog }}</span>
      </p>
      <p>
        【方向】：<span>{{ dataList.direction }}</span>
      </p>
    </div>
    <hr />
    <div>【题干】：</div>
    <div style="color: #4646ff" v-html="dataList.question"></div>

    <span>{{ dataList.questionType | TypeQuestion }}</span>
    <span>选项：（以下选中的选项为正确答案）</span>
    <div v-if="!show">
      <div
        v-for="item in dataList.options"
        :key="item.id"
        style="display: flex"
      >
        <span style="padding-right: 10px">{{ item.code }}</span>
        <el-checkbox
          disabled
          style="display: block"
          :checked="item.isRight === 1"
        ></el-checkbox>
        <span style="padding-left: 10px">{{ item.title }}</span>
      </div>
    </div>
    <div v-if="show">
      <div
        v-for="item in dataList.options"
        :key="item.id"
        style="display: flex"
      >
        <span style="padding-right: 10px">{{ item.code }}</span>
        <el-radio
          disabled
          v-model="radio"
          style="display: block"
          :label="item.isRight"
          >{{ item.title }}
        </el-radio>
      </div>
    </div>

    <hr />
    <div>
      【参考答案】：<el-button type="danger" @click="videoShow = true"
        >视频答案预览</el-button
      >
    </div>
    <video
      width="440"
      height="330"
      controls="controls"
      autoplay
      :src="dataList.videoURL"
      v-if="videoShow"
    ></video>
    <hr />
    <div>【答案解析】：<span v-html="dataList.answer"></span></div>
    <hr />
    <div>
      <!-- 【题目备注】：<span>{{ dataListNaNpxarks }}</span> -->
    </div>
    <div style="text-align: right">
      <el-button type="primary" @click="closeEvent">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  model: {
    prop: 'isShow'
  },
  props: {
    isShow: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      radio: 1,
      show: false,
      videoShow: false,
      nameList: '',
      dataList: ''
    }
  },
  watch: {
    dataList () {
      // console.log(this.dataList.questionType)
      if (this.dataList.questionType === '1') {
        this.show = true
        // console.log(this.show, !this.show)
      } else if (this.dataList.questionType === '2') {
        this.show = false
        // console.log(this.show, !this.show)
      }
    }
  },
  // updated () {
  //   console.log(this.dataList)
  //   console.log(this.show, !this.show, this.dataList.questionType)

  //   if (this.dataList.questionType === '1') {
  //     this.show = true
  //     console.log(this.show, !this.show)
  //   }
  // },
  methods: {
    closeEvent () {
      this.$emit('input', false)
      this.videoShow = false
    }
  }
}
</script>

<style lang="scss" scoped>
.box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  p {
    width: 15.625rem;
  }
}
</style>
